<?php
$TaskId=$_GET['TaskId'];
$dsn = "sqlsrv:Server=localhost;Database=Task";
$db = new PDO($dsn, "sa", "123456");
$sql = "select * from Task where TaskId='{$TaskId}'";
$statement= $db->query($sql);
$result = $statement->fetch(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>任务详情</title>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script src="js/jquery.js"></script>
</head>
<body>
<div id="container">
    <a href="task_list.php">返回任务列表</a>
    <form>
        <table class="update">
            <caption>
                <h3>任务详情</h3>
            </caption>
            <tr>
                <td>任务名称：</td>
                <td><?php echo $result['TaskName']; ?></td>
            </tr>
            <tr>
                <td>任务状态：</td>
                <td><?php
                    if ($result['TaskStatus'] == 1) {
                        echo '新创建';
                    } else if ($result['TaskStatus'] == 2) {
                        echo '进行中';
                    } else if ($result['TaskStatus'] == 3) {
                        echo '已完成';
                    }
                    ?>
                </td>            </tr>
            <tr>
                <td>任务内容：</td>
                <td><textarea cols="60" rows="15"
                              readonly="readonly"><?php echo $result['TaskContent']; ?></textarea></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <a class="update_ing" href="detail_underway.php?TaskId=<?php echo $TaskId?>"onclick='return working();'>标记为进行中</a>
                    <script>
                        function working()
                        {
                            if(confirm("标记为进行中？"))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    </script>
                    <a class="update_ing" href="detail_finished.php?TaskId=<?php echo $TaskId?> " onclick='return finished();'>标记为已完成</a>
                    <script>
                        function finished()
                        {
                            if(confirm("标记为已完成？"))
                            {
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    </script>
                </td>
            </tr>
        </table>
    </form>
</div>
<script src="js/main.js"></script>
</body>
</html>

